#include "Event.h"

namespace GPUCC
{
	namespace CPU
	{
		Event::Event(bool IsSignaled, bool AutoReset) : m_Event(NULL)
		{
			this->m_Event = CreateEvent(NULL, AutoReset, IsSignaled, NULL);
		}

		Event::~Event()
		{
			CloseHandle(this->m_Event);
		}

		bool Event::Set()
		{
			return (SetEvent(this->m_Event));
		}

		bool Event::Reset()
		{
			return (ResetEvent(this->m_Event));
		}

		bool Event::Wait(unsigned int Timeout)
		{
			bool Result = false;

			DWORD WaitResult = WaitForSingleObject(this->m_Event, Timeout);

			if (WaitResult == WAIT_OBJECT_0)
			{
				Result = true;
			}		

			return (Result);
		}
	}
}